package com.EpidemicPrevention.service;


import com.EpidemicPrevention.mapper.ApplyMapper;
import com.EpidemicPrevention.pojo.Apply;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ApplyServiceImpl implements ApplyService{
    @Autowired
    private ApplyMapper applyMapper;

    @Override
    public JSON addApply(Apply apply) {
        JSONObject json = new JSONObject();
        int code =0;
        code = applyMapper.addApply(apply);
        if (code ==1){
            json.put("msg","添加成功");
            json.put("code",1);
        }else {
            json.put("msg","添加失败");
            json.put("code",0);
        }
        return json;
    }

    @Override
    public JSON deleteApply(int v_id) {
        JSONObject json = new JSONObject();
        int code =0;
        code = applyMapper.deleteApply(v_id);
        if (code ==1){
            json.put("msg","删除成功");
            json.put("code",1);
        }else {
            json.put("msg","删除失败");
            json.put("code",0);
        }
        return json;
    }

    @Override
    public JSON updateApply(Apply apply) {
        JSONObject json = new JSONObject();

        int code=0;
        code=applyMapper.updateApply(apply);
        if (code==1){
            json.put("msg","修改入校信息成功");
            json.put("code",1);
        }else{
            json.put("msg","修改入校信息失败");
            json.put("code",0);
        }

        return json;
    }

    @Override
    public List<Apply> queryApply (int page, int limit) {
        return applyMapper.queryApply(page, limit);
    }
}
